#include <cstdio>
#include "drawclasses.hpp"
#include "vectclasses.hpp"


Vector Draw::drawNormalize(Vector &a)
{
    int k = a.maxPlace();
    int length = a.getLength();
    double max = a.at(k);
    Vector newVect(a);
    for (int i = 0; i < length; i++)
    {
        newVect.at(i) /= max;
    }
    return newVect;
}

void Draw::drawDigit(Vector & digit)
{
    int rows = 28;
    int cols = 28;

    Vector normedvect(drawNormalize(digit));
    for (int i = 0; i < rows; i++)
    {
        for (int j = 0; j < cols; j++)
        {
            if (normedvect.at(i*cols+j) < 0.3)
            {
                printf(" ");
            }
            else if (normedvect.at(i*cols+j) < 0.6)
            {
                printf("-");
            }
            else
            {
                printf("*");
            }
        }
        printf("\n");
    }
    printf("\n");
}

void Draw::drawClasses(VectorArray & classes)
{
    int vectnum = classes.getVectNumber();
    int rows = 28;
    int cols = 28;
    for (int i = 0; i < vectnum; i++)
    {
        drawDigit(classes.getVector(i));
    }
}
